package com.zhiwei.msf.infra.oauth.controller;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * function: 获取认证用户信息
 * author: zhiwei_yang
 * time: 2021/7/14-16:22
 */
@RestController
@RequestMapping("/authentication")
public class AuthenticationController {

    /**
     * 获取认证用户名: User权限
     * @param user 认证用户信息
     * @return
     */
    @GetMapping("/user/info")
    @ResponseBody
    public User getUserInfo(@AuthenticationPrincipal User user) {
        return user;
    }
}